package com.itheima.controller.admin;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.pojo.BusinessReportVO;
import com.itheima.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
@RequestMapping("/report")
@Slf4j
public class ReportController {

    @Autowired
    private ReportService reportService;

    /**
     * 会员数量统计
     * @return
     */
    @GetMapping("/getMemberReport")
    public Result getMemberReport(){
        Map map = reportService.getMemberReport();
        return new Result(true, MessageConstant.GET_MEMBER_NUMBER_REPORT_SUCCESS, map);
    }

    /**
     * 套餐预约占比
     * @return
     */
    @GetMapping("/getSetmealReport")
    public Result getSetmealReport(){
        Map map = reportService.getSetmealReport();
        return new Result(true, MessageConstant.GET_SETMEAL_COUNT_REPORT_SUCCESS, map);
    }

    /**
     * 运营数据统计
     */
    @GetMapping("/getBusinessReportData")
    public Result getBusinessReportData(){
        BusinessReportVO businessReportVO = reportService.getBusinessReportData();
        return new Result(true, MessageConstant.GET_MEMBER_NUMBER_REPORT_SUCCESS, businessReportVO);
    }

    /**
     * 导出excel
     */
    @GetMapping("/exportBusinessReport")
    public void exportBusinessReport(HttpServletResponse response){
        reportService.exportBusinessReport(response);
    }

    /**
     * 导出PDF
     */
    @GetMapping("/exportBusinessReport4PDF")
    public void exportBusinessReport4PDF(HttpServletResponse response){
        reportService.exportBusinessReport4PDF(response);
    }
}
